package com.yuan.gather.model;

import com.fasterxml.jackson.annotation.JsonInclude;
import lombok.Getter;
import lombok.Setter;

import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlTransient;
import java.io.Serializable;

/**
 * 采集结果匹配规则
 *
 * @author zhaoff
 */
@Getter
@Setter
@XmlAccessorType(XmlAccessType.FIELD)
@JsonInclude(JsonInclude.Include.NON_EMPTY)
public class GatherDetailRule implements Cloneable, Serializable {

    private static final long serialVersionUID = -5847337163315773141L;

    /**
     * 规则的名字
     */
    @XmlAttribute
    private String name;

    /**
     * el格式的表达式
     */
    private String expression;

    /**
     * groovy格式的表达式
     */
    private String script;

    /**
     * 表达式执行的结果类型
     */
    @XmlElement(name = "type")
    private String resultType;

    /**
     * 预期的值
     */
    private String result;

    /**
     * 异常级别
     */
    private int level;

    /**
     * 异常级别的名称
     */
    @XmlElement(name = "name")
    private String levelName;

    /**
     * 规则描述
     */
    private String description;

    /**
     * 错误信息
     */
    @XmlTransient
    private String errorMsg;

    @Override
    public GatherDetailRule clone() throws CloneNotSupportedException {
        return (GatherDetailRule) super.clone();
    }
    
}
